// src\nodeServer\server2.js
const express = require('express');
const app = express();

app.use((request, err, next) => {
    console.log("服务2被访问");
    next();
})

app.get('/cars',(request,response)=>{
    const cars=[
        {id:"001",name:"宝马",price:100},
        {id:"002",name:"奔驰",price:120},
        {id:"003",name:"长安",price:103},
    ]
    response.send(cars);
})

app.listen(5001,(err)=>{
    if(!err) console.log("服务器2启动成功,访问地址是http://localhost:5001/cars");
})